#include "StdAfx.h"
#include "CCommandHistory.h"


CCommandHistory::CCommandHistory()
{
	Clear();
}

void CCommandHistory::Clear()
{
	m_strHistory.clear();
	m_iterCurrent = m_strHistory.end();
}

void CCommandHistory::Push( const csString & command )
{
	m_strHistory.push_back( command );
	m_iterCurrent = m_strHistory.end();
}

csString CCommandHistory::GetPrevCommand()
{
	if ( m_iterCurrent != m_strHistory.begin() )
		m_iterCurrent--;

	if ( m_iterCurrent == m_strHistory.end() )
		return csString();

	return (*m_iterCurrent);
}

 csString CCommandHistory::GetNextCommand()
{
	if ( m_iterCurrent != m_strHistory.end() )
		m_iterCurrent++;

	if ( m_iterCurrent == m_strHistory.end() )
		return csString();

	return (*m_iterCurrent);
}

